/*
 * Copyright (c) 2011 Ball State University
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package edu.bsu.android.gtv.apps.bconnected.parser;

import java.util.List;

import android.app.Activity;

import edu.bsu.android.gtv.apps.bconnected.parser.AndroidSaxServiceParser;
import edu.bsu.android.gtv.apps.bconnected.parser.ServiceParser;
import edu.bsu.android.gtv.apps.bconnected.util.BSUPrivate;
import edu.bsu.android.gtv.apps.bconnected.util.LoginHelper;
import edu.bsu.android.gtv.apps.bconnected.util.Constants;

/**
 * Handles the calls to the various service parsers
 * @author Kyle Parker, University Computing Services
 */
public abstract class ParserFactory {
	/**
	 * 
	 * @param intServiceType
	 * @param querystringParms
	 * @return AndroidSaxServiceParser
	 */
	// DONE: Need to pass in the "type" (instructor, course, etc) and a List<String> for the querystring parms
	public static ServiceParser getParser(int intServiceType, List<String> querystringParms, Activity activity) {
		switch (intServiceType) {
			case Constants.SERVICE_TYPE_ADVISOR:
				if (LoginHelper.isDemoAccount(activity)) {
					return new AndroidSaxServiceParser(BSUPrivate.DEMO_SERVICE_URL + BSUPrivate.ADVISOR_URL, querystringParms);
				} else {
					return new AndroidSaxServiceParser(BSUPrivate.SERVICE_URL + BSUPrivate.ADVISOR_URL, querystringParms);
				}
			case Constants.SERVICE_TYPE_CLASSMATE:
				if (LoginHelper.isDemoAccount(activity)) {
					return new AndroidSaxServiceParser(BSUPrivate.DEMO_SERVICE_URL + BSUPrivate.CLASSMATE_URL, querystringParms);
				} else {
					return new AndroidSaxServiceParser(BSUPrivate.SERVICE_URL + BSUPrivate.CLASSMATE_URL, querystringParms);
				}
			case Constants.SERVICE_TYPE_CONTENT:
				return new AndroidSaxServiceParser(BSUPrivate.SERVICE_URL + BSUPrivate.CONTENT_URL, querystringParms);
			case Constants.SERVICE_TYPE_DEGREE:
				if (LoginHelper.isDemoAccount(activity)) {
					return new AndroidSaxServiceParser(BSUPrivate.DEMO_SERVICE_URL + BSUPrivate.DEGREE_URL, querystringParms);
				} else {
					return new AndroidSaxServiceParser(BSUPrivate.SERVICE_URL + BSUPrivate.DEGREE_URL, querystringParms);
				}
			case Constants.SERVICE_TYPE_EVENT:
				return new AndroidSaxServiceParser(BSUPrivate.SERVICE_URL + BSUPrivate.EVENT_URL, querystringParms);
			case Constants.SERVICE_TYPE_EVENT_INFO:
				return new AndroidSaxServiceParser(BSUPrivate.SERVICE_URL + BSUPrivate.EVENT_INFO_URL, querystringParms);
			case Constants.SERVICE_TYPE_HOUSING:
				if (LoginHelper.isDemoAccount(activity)) {
					return new AndroidSaxServiceParser(BSUPrivate.DEMO_SERVICE_URL + BSUPrivate.HOUSING_URL, querystringParms);
				} else {
					return new AndroidSaxServiceParser(BSUPrivate.SERVICE_URL + BSUPrivate.HOUSING_URL, querystringParms);
				}
			case Constants.SERVICE_TYPE_INSTRUCTOR:
				if (LoginHelper.isDemoAccount(activity)) {
					return new AndroidSaxServiceParser(BSUPrivate.DEMO_SERVICE_URL + BSUPrivate.INSTRUCTOR_URL, querystringParms);
				} else {
					return new AndroidSaxServiceParser(BSUPrivate.SERVICE_URL + BSUPrivate.INSTRUCTOR_URL, querystringParms);
				}
			case Constants.SERVICE_TYPE_LOGOUT:
				if (LoginHelper.isDemoAccount(activity)) {
					return new AndroidSaxServiceParser(BSUPrivate.DEMO_SERVICE_URL + BSUPrivate.LOGOUT_URL, querystringParms);
				} else {
					return new AndroidSaxServiceParser(BSUPrivate.SERVICE_URL + BSUPrivate.LOGOUT_URL, querystringParms);
				}
			case Constants.SERVICE_TYPE_MEMBER:
				if (LoginHelper.isDemoAccount(activity)) {
					return new AndroidSaxServiceParser(BSUPrivate.DEMO_SERVICE_URL + BSUPrivate.MEMBER_URL, querystringParms);
				} else {
					return new AndroidSaxServiceParser(BSUPrivate.SERVICE_URL + BSUPrivate.MEMBER_URL, querystringParms);
				}
			case Constants.SERVICE_TYPE_ORGANIZATION:
				if (LoginHelper.isDemoAccount(activity)) {
					return new AndroidSaxServiceParser(BSUPrivate.DEMO_SERVICE_URL + BSUPrivate.ORGANIZATION_URL, querystringParms);
				} else {
					return new AndroidSaxServiceParser(BSUPrivate.SERVICE_URL + BSUPrivate.ORGANIZATION_URL, querystringParms);
				}
			case Constants.SERVICE_TYPE_ORGANIZATION_CATEGORY:
				return new AndroidSaxServiceParser(BSUPrivate.SERVICE_URL + BSUPrivate.ORGS_CATEGORY_URL, querystringParms);
			case Constants.SERVICE_TYPE_ORGANIZATION_INFO:
				if (LoginHelper.isDemoAccount(activity)) {
					return new AndroidSaxServiceParser(BSUPrivate.DEMO_SERVICE_URL + BSUPrivate.ORGANIZATION_INFO_URL, querystringParms);
				} else {
					return new AndroidSaxServiceParser(BSUPrivate.SERVICE_URL + BSUPrivate.ORGANIZATION_INFO_URL, querystringParms);
				}
			case Constants.SERVICE_TYPE_OTHER_COURSES:
				if (LoginHelper.isDemoAccount(activity)) {
					return new AndroidSaxServiceParser(BSUPrivate.DEMO_SERVICE_URL + BSUPrivate.OTHER_COURSES_URL, querystringParms);
				} else {
					return new AndroidSaxServiceParser(BSUPrivate.SERVICE_URL + BSUPrivate.OTHER_COURSES_URL, querystringParms);
				}
			case Constants.SERVICE_TYPE_PERSON:
				if (LoginHelper.isDemoAccount(activity)) {
					return new AndroidSaxServiceParser(BSUPrivate.DEMO_SERVICE_URL + BSUPrivate.PERSON_URL, querystringParms);
				} else {
					return new AndroidSaxServiceParser(BSUPrivate.SERVICE_URL + BSUPrivate.PERSON_URL, querystringParms);
				}
			case Constants.SERVICE_TYPE_ROOMMATE:
				if (LoginHelper.isDemoAccount(activity)) {
					return new AndroidSaxServiceParser(BSUPrivate.DEMO_SERVICE_URL + BSUPrivate.ROOMMATE_URL, querystringParms);
				} else {
					return new AndroidSaxServiceParser(BSUPrivate.SERVICE_URL + BSUPrivate.ROOMMATE_URL, querystringParms);
				}
			case Constants.SERVICE_TYPE_SCHEDULE:
				if (LoginHelper.isDemoAccount(activity)) {
					return new AndroidSaxServiceParser(BSUPrivate.DEMO_SERVICE_URL + BSUPrivate.SCHEDULE_URL, querystringParms);
				} else {
					return new AndroidSaxServiceParser(BSUPrivate.SERVICE_URL + BSUPrivate.SCHEDULE_URL, querystringParms);
				}
			case Constants.SERVICE_TYPE_SHARED_COURSE:
				if (LoginHelper.isDemoAccount(activity)) {
					return new AndroidSaxServiceParser(BSUPrivate.DEMO_SERVICE_URL + BSUPrivate.SHARED_COURSES_URL, querystringParms);
				} else {
					return new AndroidSaxServiceParser(BSUPrivate.SERVICE_URL + BSUPrivate.SHARED_COURSES_URL, querystringParms);
				}
			case Constants.SERVICE_TYPE_TERM:
				if (LoginHelper.isDemoAccount(activity)) {
					return new AndroidSaxServiceParser(BSUPrivate.DEMO_SERVICE_URL + BSUPrivate.TERM_URL, querystringParms);
				} else {
					return new AndroidSaxServiceParser(BSUPrivate.SERVICE_URL + BSUPrivate.TERM_URL, querystringParms);
				}
			default: 
				return null;
		}
	}
}